<?php

namespace App\Http\Controllers\Api;

use App\Http\Resources\ProgramResource;
use App\Program;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ProgramsController extends Controller
{
    public function index()
    {
//        return ProgramResource::collection(Program::all());//展示所有json数据
        return ProgramResource::collection(Program::all());//展示所有json数据
    }

    public function show($id)
    {
        return ProgramResource::make(Program::find($id));//显示单一数据
    }
    public function setTime(Request $request)
    {
        $program = Program::find($request->id);
        $program->download++;
        $program->save();

        return response()->json(['status' => true,'下载数' => $program->download])->setStatusCode(201);
    }
}
